package com.ruoyi.web.controller.business.order;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.business.base.PageParam;
import com.ruoyi.business.order.domain.JbApprovalFormData;
import com.ruoyi.business.order.service.JbApprovalFormDataService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.core.JoR;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 审批表单数据 Controller
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Api("审批表单数据")
@RestController
@RequestMapping("/approval_form_data")
public class JbApprovalFormDataController extends BaseController
{
    @Autowired
    private JbApprovalFormDataService service;

    /**
     * 查询列表
     */
    @ApiOperation("查询列表")
    @GetMapping("/list")
    public TableDataInfo list(PageParam page, JbApprovalFormData entity)
    {
        LambdaQueryWrapper<JbApprovalFormData> select = new LambdaQueryWrapper<>();
        select.eq(JbApprovalFormData::getType, entity.getType())
        ;

        IPage<JbApprovalFormData> iPage = service.page(page.b(), select);
        return JoR.rows(iPage);
    }

    /**
     * 新增
     */
    @ApiOperation("新增")
    @PostMapping
    public AjaxResult add(@RequestBody JbApprovalFormData entity)
    {
        return toAjax(service.save(entity));
    }

    /**
     * 修改
     */
    @ApiOperation("修改")
    @PutMapping
    public AjaxResult edit(@RequestBody JbApprovalFormData entity)
    {
        return toAjax(service.updateById(entity));
    }

    /**
     * 删除
     */
    @ApiOperation("删除")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(service.removeByIds(Arrays.asList(ids)));
    }
}
